package com.s2m;

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths;

import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;

public class Swagger2MarkupMain {
	public static void main(String[] args) throws MalformedURLException {
		// 输出Ascii格式
		Swagger2MarkupConfig configASCIIDOC = new Swagger2MarkupConfigBuilder()
				.withMarkupLanguage(MarkupLanguage.ASCIIDOC).withOutputLanguage(Language.ZH)
				.withPathsGroupedBy(GroupBy.TAGS).withGeneratedExamples().withoutInlineSchema().build();
		// 输出MARKDOWN格式
		Swagger2MarkupConfig configMARKDOWN = new Swagger2MarkupConfigBuilder()
				.withMarkupLanguage(MarkupLanguage.MARKDOWN).withOutputLanguage(Language.ZH)
				.withPathsGroupedBy(GroupBy.TAGS).withGeneratedExamples().withoutInlineSchema().build();
//		// 输出测试
//		Swagger2MarkupConfig configTest = new Swagger2MarkupConfigBuilder()
//				.withMarkupLanguage(MarkupLanguage.CONFLUENCE_MARKUP).build();

		Swagger2MarkupConverter.from(new URL("http://10.1.62.120:38081/emr-server/v2/api-docs"))
				.withConfig(configASCIIDOC).build().toFile(Paths.get("src/docs/asciidoc/generated/index"));

		Swagger2MarkupConverter.from(new URL("http://10.1.62.120:38081/emr-server/v2/api-docs"))
				.withConfig(configMARKDOWN).build().toFile(Paths.get("src/docs/asciidoc/markdown/index"));

//		Swagger2MarkupConverter.from(new URL("http://10.1.62.120:38081/emr-server/v2/api-docs")).withConfig(configTest)
//		.build().toFile(Paths.get("src/docs/asciidoc/html/index"));
	}
}
